import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:short_drama/models/Invite_model.dart';
import 'package:short_drama/utils/colors.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:short_drama/utils/float.dart';

class InvitePage extends StatefulWidget {
  const InvitePage({Key? key}) : super(key: key);

  State<InvitePage> createState() => _InvitePageState();
}

class _InvitePageState extends State<InvitePage> {
  @override
  void initState() {
    super.initState();
    _fetchData();
  }

  Future<void> _fetchData() async {
    try {
      final shareUrl = await InviteViewModel().fetchInviteData();
      setState(() {});
    } catch (e) {
      print('获取数据失败');
      setState(() {});
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: ClientColors.ff0a0f12,
      appBar: AppBar(
        iconTheme: IconThemeData(color: Colors.white),
        leading: IconButton(
          onPressed: () => {Get.back()},
          icon: Icon(Icons.arrow_back_ios),
        ),
        backgroundColor: ClientColors.odffffff,
        centerTitle: false,
        titleSpacing: FloatConstance.navBarSpace,
        title: Text(
          '邀请好友',
          style: TextStyle(color: Colors.white, fontSize: 18),
        ),
      ),
      body: Container(
        margin: EdgeInsets.only(left: 32, top: 28, right: 32),
        padding: EdgeInsets.all(12),
        decoration: BoxDecoration(
          color: ClientColors.odffffff,
          borderRadius: BorderRadius.circular(10),
          image: DecorationImage(
            image: AssetImage('assets/images/icon_bg_green.png'),
            fit: BoxFit.cover,
          ),
        ),
        child: AspectRatio(
          aspectRatio: 1 / 1.4,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            children: [
              Text(
                '邀请好友加入',
                style: TextStyle(fontSize: 22, color: Colors.white),
              ),
              Image.asset('assets/images/icon_user_qrcode.png'),
              Text(
                '分享二维码即刻邀请好友',
                style: TextStyle(fontSize: 14, color: Colors.white),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
